//
//  SDHSportsTeamProfileVC.m
//  SDHSportsNews
//
//  Created by MichaelShan on 2021/3/9.
//

#import "SDHSportsTeamProfileVC.h"
#import "MTARichLabel.h"

@interface SDHSportsTeamProfileVC ()

@property (nonatomic, strong) MTARichLabel *contentLb;

@end

@implementation SDHSportsTeamProfileVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColorFromRGB(81, 81, 81);
    __weak typeof(self) weakSelf = self;
    
    MTARichLabel *label = [MTARichLabel new];
    label.textAlignment = NSTextAlignmentLeft;
    label.numberOfLines = 0;
    label.text = @"team profile";
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:label];
    self.contentLb = label;

    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.view).offset(10);
        make.centerX.equalTo(weakSelf.view);
        make.left.equalTo(weakSelf.view).offset(10);
        make.right.equalTo(weakSelf.view).offset(-10);
    }];
    
    
    [self loadData];
}

- (void)loadData {
    [MBProgressHUD showLoading];
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
//        self.tabInfoDic[@"team_id"];
        NSString *teamid = @"145868";
        NSString *requestUrl = [NSString stringWithFormat:@"http://jsuywu8.com/guojitiyu/Tiyu1/teamProfile?id=%@", teamid];
        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:requestUrl]];
        NSError *err;
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data
                                                            options:NSJSONReadingMutableContainers
                                                              error:&err];
        
        if (dic) {
            dispatch_async(dispatch_get_main_queue(), ^{
                self.contentLb.text = [dic objectForKey:@"data"];
                [MBProgressHUD hideHUD];
            });
        }
        NSLog(@"dic: %@", dic);
    });
}

@end
